<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/my_site.css"/>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style type="text/css">
			.mui-btn-warning{
				box-shadow:0px 3px 10px #FF8282;
			}	
			.mui-btn-blue, .mui-btn-primary, input[type=submit]{background-color: #5763FF;}
			.mui-input-row .mui-input-clear~.mui-icon-clear, .mui-input-row .mui-input-password~.mui-icon-eye, .mui-input-row .mui-input-speech~.mui-icon-speech{top: 20px!important;}
		</style>
	</head>

	<body>
	<!--------头部返回收货地址----------->
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <a class="mui-pull-right" style="color: #5763FF;font-size: 16px;line-height: 45px;" id="btn">保存</a>
		    <h1 class="mui-title">标题</h1>
		</header>
	<!--------填写新增地址信息----------->
		<div class="mui-content" style="background:white;">
			<div class="mui-input-group">
				<div class="mui-input-row" style="height:60px;line-height: 60px;">
					<label style="height:60px;line-height: 60px;">收货人:</label>
					<input type="text" class="mui-input-clear" placeholder="请输入名字" value="" id="name">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">手机号码：</label>
					<input type="text" class="mui-input-clear" placeholder="请输入您的手机号码" value="" id="mobile">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">所在城市：</label>
					<input type="text" class="mui-input-clear" placeholder="填写您所在的城市" value="" id="city">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">收货地址：</label>
					<input type="text" class="mui-input-clear" placeholder="填写所在的街道/小区" value="" id="address">
				</div>
				
			</div>
			
	<!--------保存收货信息----------->
			<div class="mui-button-row" style="background:white;margin-top:22px;">
				<button type="button" class="mui-btn mui-btn-warning" style="width:95%;height:50px;background:#FF6060;" id="btn_delete" >删除收货信息</button>
			</div>
		</div>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<!--<script src="http://dcloud.io/hellomui/js/mui.picker.js" type="text/javascript" ></script>
	<script src="http://dcloud.io/hellomui/js/mui.poppicker.js" type="text/javascript" ></script>
	<script src="http://dcloud.io/hellomui/js/city.data.js" type="text/javascript" ></script>-->
	
	<script type="text/javascript">
			function GetQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return unescape(r[2]);
				return null;
			}
			var checked = GetQueryString("id");
			console.log(checked);
		
		var a = localStorage.state;
		var b = localStorage.data;
			$.ajax({
				type:"post",
				url:"http://mall.itcn99.com/i/index/edit_address",
				async:true,
				dataType:'jsonp',
				data:{
					"uid":b,
					"aid":checked,
				},
				success:function(data){
					console.log(data)
					$('#name').val(data.data.name);
					$('#mobile').val(data.data.mobile);
					$('#city').val(data.data.city);
					$('#address').val(data.data.address);	
				}
			});
			$("#btn").click(function(){
				var name = $("#name").val();
				var mobile = $("#mobile").val();
				var city = $("#city").val();
				var address = $("#address").val();
				console.log(name)
				console.log(mobile)
				console.log(city)
				console.log(address)
				$.ajax({
					type:"post",
					url:"http://mall.itcn99.com/i/index/update_address",
					async:true,
					dataType:'jsonp',
						data:{
							"uid":b,
							"aid":checked,
							"username":name,
							"mobile":mobile,
							"city":city,
							"address":address,
						},
						success:function(data){
							console.log(data)
							var state = data.state;
							if(state == 1){
								mui.alert("","修改成功",function(){
									window.location.href="shipping_address.html";
								})
							}else if(state == 0){
								mui.alert("","修改失败");
							}
						}
					});
				})
			$("#btn_delete").click(function(){
				$.ajax({
					type:"post",
					url:"http://mall.itcn99.com/i/index/del_address",
					async:true,
					dataType:'jsonp',
					data:{
						"uid":b,
						"aid":checked,
					},
					success:function(data){
						console.log(data)
						var state = data.state;
						if(state == 1){
							mui.alert("","删除成功",function(){
								window.location.href="shipping_address.html";
							});
						}else if(state == 0){
							mui.alert("","删除失败");
						}
					}
				});
			})
			
			
	</script>
	<!--<script type="text/javascript">
			(function($, doc) {
				$.init();
				$.ready(function() {
					//级联示例
					var cityPicker = new $.PopPicker({
						layer: 2
					});
					cityPicker.setData(cityData);
					var showCityPickerButton = doc.getElementById('city');
					var cityResult = doc.getElementById('city');
					showCityPickerButton.addEventListener('tap', function(event) {
						cityPicker.show(function(items) {
							cityResult.value = items[0].text + " " + items[1].text;
						});
					}, false);
				});	
			})(mui, document);
	</script>	-->
</html>